package ltd.trackan.messagecenter.email.formatted;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 京东新旧农场 收获格式化
 *
 * @author wxa
 */
public class JDFarmGet extends FormattedBasics {
    public JDFarmGet(String mailContent) {
        // 每个人信息分开
        String[] everyone = mailContent.split("<br>(<br>)+");
        for (String personalInformation : everyone) {
            // 获得第一行
            String[] oneLine = personalInformation.split("<br>");
            // 匹配内容
            Pattern pattern;
            Matcher matcher;
            // 可能是两种形式
            if (Pattern.matches("【.*", oneLine[0])) {
                pattern = Pattern.compile("】(\\S*)");
                matcher = pattern.matcher(oneLine[0]);
            } else {
                pattern = Pattern.compile("\\s(\\S*)");
                matcher = pattern.matcher(oneLine[0]);
            }
            while (matcher.find()) {
                hashMap.put(matcher.group(1), personalInformation);
            }
        }
    }
}
